package cn.azzhu.day01

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.streaming.api.scala._

/**
 * @author azzhu
 * @create 2020-09-17 23:25:15
 */
object BatchScalaWordCount {
  def main(args: Array[String]): Unit = {
    val env = ExecutionEnvironment.getExecutionEnvironment

    val lines = env.readTextFile("data/word")

    val words = lines.flatMap(_.split(" "))

    val wordAndOne = words.map((_, 1))

    val summed = wordAndOne.groupBy(0).sum(1)

    summed.writeAsText("data/result")

    env.execute("BatchScalaWordCount")
  }
}
